package case1.adapter;

import case1.Quackable;
import case1.goose.Goose;
import case1.core.observer.Observable;
import case1.core.observer.Observer;

/**
 * @author yuanml
 */
public class GooseDuckAdapter implements Quackable {
    private Goose goose;
    private final Observable observable;

    public GooseDuckAdapter(Goose goose) {
        this.goose = goose;
        observable = new Observable(this);
    }

    @Override
    public void quack() {
        goose.honk();
        notifyObserver();
    }

    @Override
    public void registerObserver(Observer observer) {
        observable.registerObserver(observer);
    }

    @Override
    public void notifyObserver() {
        observable.notifyObserver();
    }
}
